﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class apps_apps_rs_3_rs : System.Web.UI.Page
{
    string codenguoidcboithuong = "";
    string codeslngdcboithuong = "";
    string tenbt1, tenbt2, tenbt3;
    string diachibt1, diachibt2, diachibt3;
    string slngboithuong = "";
    string tenngbt1, tenngbt2, tenngbt3;
    string diachi1, diachi2, diachi3;
    bool check1, check2, check3, check4;
    string tienboithuong;
    string dkbosung;
    string ngaykyvb;
    string hoatdong;

    protected void Page_Load(object sender, EventArgs e)
    {
        System.Text.StringBuilder displayValues = new System.Text.StringBuilder();
        System.Collections.Specialized.NameValueCollection postedValues = Request.Form;
        String nextKey;
        for (int i = 0; i < postedValues.AllKeys.Length; i++)
        {
            nextKey = postedValues.Keys[i];
            if (nextKey.Substring(0, 2) != "__")
            {
                // displayValues.Append("<br>");
                //displayValues.Append(nextKey);
                //displayValues.Append(" = ");
                displayValues.Append(postedValues[i]);
                displayValues.Append("|");
            }
        }
        Label1.Text = displayValues.ToString();
        string str = displayValues.ToString();
        string[] chuoitach2 = str.Split('|');
        //bat dau lay gia tri tu chuoi
        codeslngdcboithuong = chuoitach2[2];
        tenbt1 = chuoitach2[3];
        tenbt2 = chuoitach2[5];
        tenbt3 = chuoitach2[7];

        slngboithuong = chuoitach2[9];
        tenngbt1 = chuoitach2[11];
        tenngbt2 = chuoitach2[14];
        tenngbt3 = chuoitach2[17];
        if (chuoitach2[27] != null)
        {
            lblnky.Text = chuoitach2[27];
            lbNgayky2.Text = chuoitach2[27];
        }
        if (chuoitach2[27] == null || chuoitach2[27] == "")
        {
            lblnky.Text = "the day__________ of _______";
            lbNgayky2.Text = "the day__________ of _______";
        }
        // Bat dau ng dc Boi thuong
        if (codeslngdcboithuong == "1")
        {
            lblDBT.Text = tenbt1 + " of " + chuoitach2[4];
            test.InnerHtml = "<br/> ______________________ <br/>" + tenbt1 + " (Indemnitee)";
        }
        else if (codeslngdcboithuong == "2")
        {
            lblDBT.Text = tenbt1 + " of " + chuoitach2[4] + " , and ";
            lblDBT.Text += tenbt2 + " of " + chuoitach2[6];
            test.InnerHtml = "<br/> ______________________ <br/>" + tenbt1 + " (Indemnitee)";
            test.InnerHtml += "<br/> ______________________ <br/>" + tenbt2 + " (Indemnitee) <br>";

            testwitness.InnerHtml = "<br>___________________________<br> (Witness) <br>";
            testwitness.InnerHtml += "<br>___________________________<br> (Witness) <br>";
        }
        else if (codeslngdcboithuong == "3")
        {
            lblDBT.Text = tenbt1 + " of " + chuoitach2[4] + " , and ";
            lblDBT.Text += tenbt2 + " of " + chuoitach2[6] + " , and ";
            lblDBT.Text += tenbt3 + " of " + chuoitach2[6];
            test.InnerHtml = "<br/> ______________________________ <br/>" + tenbt1 + " (Indemnitee)";
            test.InnerHtml += "<br/> _____________________________ <br/>" + tenbt2 + " (Indemnitee) <br>";
            test.InnerHtml += "<br/> _____________________________ <br/>" + tenbt3 + " (Indemnitee) <br>";
        }
        // Bat dau ng boi thuong
        if (slngboithuong == "1")
        {
            lblnguoiphaibt.Text = tenngbt1 + " of " + chuoitach2[12];
            testnguoibt31.InnerHtml = "<br/>" + tenngbt1 + " (Indemnifier)<br><br>Per: ________________________ (Seal)<br>";
        }
        else if (slngboithuong == "2")
        {
            lblnguoiphaibt.Text = tenngbt1 + " of " + chuoitach2[12] + " , and ";
            lblnguoiphaibt.Text += tenngbt2 + " of " + chuoitach2[15];

            testnguoibt31.InnerHtml = "<br>" + tenngbt1 + " (Indemnifier)<br><br>Per: ________________________ (Seal)<br><br>";
            testnguoibt31.InnerHtml += "<br>" + tenngbt2 + " (Indemnifier)<br><br>Per: ________________________ (Seal)<br><br>";

        }
        else if (slngboithuong == "3")
        {
            lblnguoiphaibt.Text = tenngbt1 + " of " + chuoitach2[12] + " , and ";
            lblnguoiphaibt.Text += tenngbt2 + " of " + chuoitach2[15] + " , and ";
            lblnguoiphaibt.Text += tenngbt3 + " of " + chuoitach2[18];
            testnguoibt31.InnerHtml = "<br>" + tenngbt1 + " (Indemnifier)<br><br>Per: ________________________ (Seal)<br><br>";
            testnguoibt31.InnerHtml += "<br>" + tenngbt2 + " (Indemnifier)<br><br>Per: ________________________ (Seal)<br><br>";
            testnguoibt31.InnerHtml += "<br>" + tenngbt3 + " (Indemnifier)<br><br>Per: ________________________ (Seal)<br><br>";
        }
        // loai hoat dong
        if (chuoitach2[19] == "hoatdong")
        {
            lblHoatdong.Text = "Activity";
        }
        else if (chuoitach2[19] == "hopdong")
        {
            lblHoatdong.Text = "Contract";
        }
        else if (chuoitach2[19] == "chothue")
        {
            lblHoatdong.Text = "Lease";
        }
        else if (chuoitach2[19] == "giaodich")
        {
            lblHoatdong.Text = "Transaction";
        }

        string mota23 = chuoitach2[20].Trim();
        if (mota23 != "")
        {
            lblMotat.Text = mota23;
        }
        else
        {
            lblMotat.Text = "____________________________________";
        }
        // bang
        string state = chuoitach2[1];
        string bang = checkBang(state);
        lblB.Text = bang;
        lbB2.Text = bang;
        // ktra co doi phi ko
        string tientraphidb = chuoitach2[25];
        if (tientraphidb != "")
        {
            lbltien.Text = chuoitach2[25] + " (USD)";
        }
        else
        {
            lbltien.Text = " no fee ";
        }
        // Ktra Session , neu da tra roi thi co the Xem + Down
        MultiView1.SetActiveView(View1);
    }
    public string checkBang(string kyhieu)
    {
        string chuoitrave = "";
        if (kyhieu == "AL")
        {
            chuoitrave = "Alabama";
        }
        else if (kyhieu == "AK")
        {
            chuoitrave = "Alaska";
        }
        else if (kyhieu == "AZ")
        {
            chuoitrave = "Arizona";
        }
        else if (kyhieu == "AR")
        {
            chuoitrave = "Arkansas";
        }
        else if (kyhieu == "CA")
        {
            chuoitrave = "California";
        }
        else if (kyhieu == "CO")
        {
            chuoitrave = "Colorado";
        }
        else if (kyhieu == "CT")
        {
            chuoitrave = "Connecticut";
        }
        else if (kyhieu == "DE")
        {
            chuoitrave = "Delaware";
        }
        else if (kyhieu == "DC")
        {
            chuoitrave = "District of Columbia";
        }
        else if (kyhieu == "FL")
        {
            chuoitrave = "Florida";
        }
        else if (kyhieu == "GA")
        {
            chuoitrave = "Georgia";
        }
        else if (kyhieu == "HI")
        {
            chuoitrave = "Hawaii";
        }
        else if (kyhieu == "ID")
        {
            chuoitrave = "Idaho";
        }
        else if (kyhieu == "IL")
        {
            chuoitrave = "Illinois";
        }
        else if (kyhieu == "IN")
        {
            chuoitrave = "Indiana";
        }
        else if (kyhieu == "IA")
        {
            chuoitrave = "Iowa";
        }
        return chuoitrave;
    }
}
